home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97a.txt / 000090_icon-group-sender _Sat Mar 22 17:31:59 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Sat, 22 Mar 1997 16:11:52 MST
  2. To: icon-group@cs.arizona.edu
  3. Date: Sat, 22 Mar 1997 17:31:59 +1000
  4. From: Stuart Robinson <Stuart.Robinson@anu.edu.au>
  5. Message-Id: <33338AEF.420@anu.edu.au>
  6. Sender: icon-group-request@cs.arizona.edu
  7. Subject: Problem with Program
  8. Errors-To: icon-group-errors@cs.arizona.edu
  9. Status: RO
  10. Content-Length: 1091
  11.  
  12. Hello.
  13.  
  14. I've run into a problem with a program that I've written and I was 
  15. hoping that someone would tell what is wrong.  I'm sure it's silly and 
  16. stupid but I am a newcomer to programming in general and Icon in 
  17. particular.
  18.  
  19. This short little program is meant to read a line and write either (1) 
  20. a tab followed by the line or (2) simply the line.  It should do (1) 
  21. if the line either contains "{Q" or follows a line with "{Q"; 
  22. otherwise, it should do (2).
  23.  
  24. I would greatly appreciate it if someone could tell me I have slipped 
  25. up.  Also, if anyone knows of an alternative strategy, I would 
  26. appreciate hearing about it.  Thanks.  (The program follows.)
  27.  
  28. ======================================================================
  29.  
  30. procedure main()
  31.  
  32. lastline := ""
  33.  
  34. while line := read() do
  35.     {
  36.     line ?
  37.         {
  38.         if find( "{Q" ) 
  39.             then 
  40.                 presentline := "quote"
  41.                 write( "\t" || line );
  42.  
  43.         else 
  44.             if lastline == "quote" 
  45.                 then 
  46.                     write( "\t" || line )
  47.                     presentline := "notquote";
  48.  
  49.         else other 
  50.             write( line )
  51.             presentline := "notquote"
  52.         }
  53.     }
  54.  
  55. lastline := presentline
  56.  
  57. end
  58.